package com.czy.controller;

import com.czy.common.annotation.SystemControllerLog;
import com.czy.common.model.Result;
import com.czy.service.ExcelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author czy
 * @date 2021-5-19 11:44
 */
@RestController
@RequestMapping("/excel")
@Api(value = "excel操作",tags = "excel操作")
@Slf4j
public class ExcelController {
    @Autowired
    private ExcelService excelService;

//    @GetMapping("/singleSheetExport")
//    @ApiOperation(value = "excel单sheet导出")
//    @SystemControllerLog(description = "excel单sheet导出")
//    public void singleSheetExport(){
//        excelService.singleSheetExport();
//    }
//
//    @GetMapping("/manySheetExport")
//    @ApiOperation(value = "excel多sheet导出")
//    @SystemControllerLog(description = "excel多sheet导出")
//    public void manySheetExport(){
//        excelService.excelExportManySheet();
//    }
//
//    @GetMapping("/templateExport")
//    @ApiOperation(value = "excel模板导出")
//    @SystemControllerLog(description = "excel模板导出")
//    public void templateExport(){
//        excelService.templateExport();
//    }

    @PostMapping("/importExcel")
    @ApiOperation(value = "excel导入")
    @SystemControllerLog(description = "excel导入")
    public Result importExcel(MultipartFile file){
        return excelService.importExcel(file);
    }

//    @GetMapping("/excelPreview")
//    @ApiOperation(value = "excel转html预览")
//    @SystemControllerLog(description = "excel转html预览")
//    public void excelPreview(HttpServletResponse response)throws IOException, InvalidFormatException {
//        ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile("excel/导出模板.xlsx")));
//        response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
//    }

}
